package com.picture.controller;
;
import com.picture.pojo.entity.TagType;
import com.picture.result.Result;
import com.picture.service.TagTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController()
@RequestMapping("/tag_type")
@Api(tags = "标记类型相关接口")
@CrossOrigin("*")
@Slf4j
public class TagTypeController {

    // 注入TagTypeService的接口对象
    @Resource
    private TagTypeService tagTypeService;

    /**
     * 查看所有的标记类型
     * @return 返回所有标记类型
     */
    @ApiOperation("查看所有的标记类型")
    @GetMapping("/check")
    public Result<List<TagType>> check() {
        return tagTypeService.check();
    }

    /**
     * 添加标记类型
     * @param typeName 标记类型名
     * @return 返回响应结果
     */
    @ApiOperation("添加标记类型")
    @PostMapping("/add")
    public Result<List<TagType>> add(@RequestParam(name = "typeName") String typeName) {
        return tagTypeService.add(typeName);
    }

    /**
     * 删除标记类型
     * @param id 标记类型id
     * @return 返回响应结果
     */
    @ApiOperation("删除标记类型")
    @DeleteMapping("/delete")
    public Result<List<TagType>> delete(@ApiParam("标记类型id") @RequestParam(name = "id") int id) {
        return tagTypeService.delete(id);
    }
}
